package pattern.strategy;

/**
 * int排序能力持有
 *
 * @author sun.ye
 * @since 2020-07-15 18:27
 */
public class IntSortHandle implements SortHandle<Integer>{

    private Integer[] array;


    @Override
    public void swap(int index) {
        Integer temp = array[index];
        array[index] = array[index + 1];
        array[index + 1] = temp;
    }

    @Override
    public void setArray(Integer[] array) {
        this.array = array;
    }

    @Override
    public int length() {
        return array.length;
    }

    @Override
    public boolean outOfOrder(int index) {
        return array[index] > array[index + 1];
    }
}